package com.xue.service.impl;

import com.xue.annotation.LogOperation;
import com.xue.mapper.DeptMapper;
import com.xue.pojo.Dept;
import com.xue.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    /*
    * 查询所有部门
    * */

    @Override
    public List<Dept> getAllDept() {


        return deptMapper.getAllDept();
    }

    /*
    * 根据id删除部门
    * */

    @Override
    public void deleteDeptById(Integer id) {
        deptMapper.deleteDeptById(id);
    }

    /*
    * 添加部门
    * */

    @Override
    public void addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.addDept(dept);
    }

    /*
    * 根据id来查询部门
    * */

    @Override
    public Dept getDeptById(Integer id) {
        return deptMapper.getDeptById(id);
    }

    /*
    * 修改部门
    * */

    @Override
    public void updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }
}
